home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: Statistically Random Number algorithm
- Date: 20 Mar 1996 15:48:19 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4iq5g3INN17g@keats.ugrad.cs.ubc.ca>
- References: <314D0B67.3C16@psu.edu> <4ikle5$1rf@sparcserver.lrz-muenchen.de>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4ikle5$1rf@sparcserver.lrz-muenchen.de>,
- Kurt Watzka <watzka@stat.uni-muenchen.de> wrote:
- >"Jason A. Soloff" <jas251@psu.edu> writes:
- >
- >>I am working on a monte carlo simulation program to model some problems
- >>in astronomy. One thing I am running into, however, is the problem of
- >>the pseudo-random number tables. Does anyone have an algorithm (or
- >>code) for a truly statistically random number generator?
- >
- >A guy from NASA once suggested that it is really simple. All you need
- >is a satelite that records the background radiation. You digitize
- >that and have a perfectly random sequence of random numbers.
-
- I just wrote code this morning that uses /dev/audio on a Sun box to produce a
- 256 byte state array for the random() function. What I do is take the least
- significant bit from each byte of a block of 2048 read from the audio device.
- I XOR these bits into a 256 byte block that is initially zero, lather, rinse
- and repeat 32 times to produce a final block. Even with the mike unplugged,
- there is enough variation in the samples that I can get a decent random block
- this way.
-
- In production, the microphone will be strategically placed next to a fan.
-
- You don't really need cosmic background radiation---just good old noise should
- do the trick.
-
- >The word algorithm implies a _deterministic_ process, and there
- >cannot be a deterministic process that produces _random_ output.
-
- Right. Even with the above /dev/audio method, the sequence is completely
- determined once you create the 256 byte vector. However, what you can do is
- periodically update the state array with new bits read from the device.
- --
-
-